#ifndef COREXMLPARSER_H
#define COREXMLPARSER_H

#include <QObject>
#include <QXmlSimpleReader>
#include <QDomElement>
#include "qxmpp/QXmppMessage.h"

class QDomNode;
class QSslSocket;
class CoreXMLHandler;

class CoreXMLParser : public QObject, public QXmlSimpleReader
{
Q_OBJECT
public:
    CoreXMLParser(QSslSocket*,QObject* parent=0);
    int clientAuthentication(QString);

signals:
    void authenticationRequest(QString,QString);
    void startParsing();
    void buddyListRequest(QString username,QString accountJid);
    void messageReceived(QXmppMessage);
    void setConnectionState(QString username, QString jid, QString state);
    void getConnectionState(QString username, QString jid = "");

public slots:
    void parseElement(QDomNode);
    void malformedXML(QString err_msg);
    void startParser();
private:
    void parseAuthRequest(QDomNode e);
    void parseString(QString);
    void parseMessage(QDomNode e);
    void parseRoster(QDomNode e);
    void parseConnection(QDomNode e);

    QString m_username;
    CoreXMLHandler* m_xmlHandler;
    QSslSocket* m_socket;
};

#endif // COREXMLPARSER_H
